﻿using System;
using System.ComponentModel;
using System.Text.RegularExpressions;

namespace OrbitOne.CRMLyncInfoDashboard.Setup
{
    public class DashboardInstaller : IDashboardInstaller
    {
        private readonly Controller m_controller;
        private IRegistryProvider m_registryProvider;
        public static readonly Guid ApplicationKey = new Guid("5A565081-C710-4987-A9FB-061B36B4B752");


        public bool OpenByDefault { get; set; }
       

        public DashboardInstaller(Controller controller)
        {
            m_controller = controller;
            m_registryProvider = new RegistryProvider();
        }

        public void Install()
        {
            var lyncExtensdionRegistryEntry = new LyncExtensionRegistryEntry(OpenByDefault, m_controller.Url, m_controller.Url, "CRM Dashboard", 0, 1);
            m_registryProvider.SaveConfiguration(lyncExtensdionRegistryEntry);
            
        }

        public void Uninstall()
        {
            m_registryProvider.DeleteConfiguration(ApplicationKey);
        }

        public bool IsInstalled()
        {
            return m_registryProvider.IsConfigurationPresent(ApplicationKey);
        }

        public void Reinstall()
        {
            Install();
        }

      
     

      
    }
}